import random
import unittest
from spaghetti import SpaghettiVM

class TestSequenceFunctions(unittest.TestCase):

    def setUp(self):
        pass

    def test_empty(self):
        code = ""
        vm = SpaghettiVM()
        vm.execute(code)
        
    def test_empty2(self):
        code = '''
        
        '''
        vm = SpaghettiVM()
        vm.execute(code)
        
    def test_empty3(self):
        code = '''
                    
        '''
        vm = SpaghettiVM()
        vm.execute(code)

    def test_mov_integer(self):
        code = '''
        MOV A,5
        '''
        vm = SpaghettiVM()
        vm.execute(code)
        assert(vm.registers["A"]==5)
        
    def test_mov_string(self):
        code = '''
        MOV A,"Hello World!"
        '''
        vm = SpaghettiVM()
        vm.execute(code)
        assert(vm.registers["A"]=="Hello World!")
        
    def test_push(self):
        code = '''
        MOV A,"TEST"
        PUSH A
        '''
        vm = SpaghettiVM()
        vm.execute(code)
        assert(vm.stack[0]=="TEST")
        
    def test_pop(self):
        code = '''
        MOV A,"TEST"
        PUSH A
        POP B
        '''
        vm = SpaghettiVM()
        vm.execute(code)
        assert(len(vm.stack)==0)
        assert(vm.registers["B"]=="TEST")
        
    def test_inc_integer(self):
        code = '''
        MOV A,5
        INC A
        '''
        vm = SpaghettiVM()
        vm.execute(code)
        assert(vm.registers["A"]==6)
        
    def test_dec_integer(self):
        code = '''
        MOV A,5
        DEC A
        '''
        vm = SpaghettiVM()
        vm.execute(code)
        assert(vm.registers["A"]==4)
        
if __name__ == '__main__':
    unittest.main()